package edu.hawaii.duedates;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.apache.commons.cli.ParseException;
import org.junit.Test;

/**
 * Test cases for Command Line Arguments.
 * @author Ka Hung Phillip Lau
 * @author Creighton Okada
 *
 */
public class TestCommandLineArguments {
  /**
   * Test case for console.
   * @throws ParseException if there is a wrong argument
   */
  @Test
  public void testConsole() throws ParseException {
    String[] params = {"-console"};
    CommandLineArguments args = new CommandLineArguments();
    args.parseArgs(params);
    
    assertTrue("Checking console usage.", args.usingConsole());
  }
  /**
   * Test case for UHM.
   * @throws ParseException if there is a wrong argument
   */
  @Test
  public void testUhm() throws ParseException {
    String[] params = {"-uhm", "00000000", "aaaa"};
    CommandLineArguments args = new CommandLineArguments();
    args.parseArgs(params);
    
    assertTrue("Check for uhm usage.", args.usingUhm());
    assertEquals("Check id.", "00000000", args.getId());
    assertEquals("Check lastname.", "aaaa", args.getLastName());
  }
  /**
   * Test case for HSL.
   * @throws ParseException if there is a wrong argument
   */
  @Test
  public void testHsl() throws ParseException {
    String[] params = {"-hsl", "1111111111", "2222"};
    CommandLineArguments args = new CommandLineArguments();
    args.parseArgs(params);
    
    assertTrue("Check for hsl usage.", args.usingHsl());
    assertEquals("Check barcode.", "1111111111", args.getBarcode());
    assertEquals("Check pin.", "2222", args.getPin());
  }
  /**
   * Test case for within argument.
   * @throws ParseException if there is a wrong argument
   */
  @Test
  public void testWithin() throws ParseException {
    String[] params = {"-within", "10"};
    CommandLineArguments args = new CommandLineArguments();
    args.parseArgs(params);
    
    assertTrue("Check for within usage.", args.usingWithin());
    assertEquals("Check day interval.", 10, args.getDayInterval());
  }
  /**
   * Test case for wakeup argument.
   * @throws ParseException if there is a wrong argument
   */
  @Test
  public void testWakeup() throws ParseException {
    String[] params = {"-wakeup", "0.001"};
    CommandLineArguments args = new CommandLineArguments();
    args.parseArgs(params);
    
    assertTrue("Check for wakeup usage.", args.usingWakeup());
    assertTrue("Check time interval.", (0.001 == args.getTimeInterval()));
  }
}
